package com.szbber.medical.viewmodel.fragment

import android.content.Context
import android.graphics.Color
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.MutableLiveData
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.szbber.commen.api.Repository
import com.szbber.commen.api.launch
import com.szbber.commen.base.BaseViewModel
import com.szbber.commen.bean.AddCareLabelBean
import com.szbber.commen.bean.NurseLevelListBean
import com.szbber.medical.R
import com.szbber.medical.databinding.ItemNurselevelBinding
import kotlinx.android.synthetic.main.fragment_nurselevel_setting.*

class NurseLevelSettingViewModel : BaseViewModel() {

    var nurseLevelListBean = MutableLiveData<NurseLevelListBean>()

    fun getNurseLevel(context: Context?) = launch(context, {
        nurseLevelListBean.value = Repository.getNurseLevel(context)
    })

    fun getEditNurseLevel(context: Context?,
        id: String,
        levelName: String?,
        fontColor: String?,
        bgColor: String?) = launch(context, {
        val queue =
            arrayOf("id", id, "levelName", levelName, "fontColor", fontColor, "bgColor", bgColor)
        Repository.getEditNurseLevel(context, *queue)
        getNurseLevel(context)
    })


    fun addNurseLevel(context: Context?, addCareLabelBean: AddCareLabelBean?) = launch(context, {
        val queue = arrayOf("bgColor",
            addCareLabelBean?.bgColor,
            "fontColor",
            addCareLabelBean?.fontColor,
            "levelName",
            addCareLabelBean?.labelName)
        Repository.addNurseLevel(context, *queue)
        getNurseLevel(context)
    })

    fun deleteNurseLevel(context: Context?, labeleId:String?) = launch(context,{
        val queue = arrayOf("labeleId",labeleId)
          Repository.deteleNurseLevel(context,*queue)
        getNurseLevel(context)
    })


}